import React from "react";

export default class Fb extends React.Component {
    state = {
        list: [0, 1]
    }

    componentDidMount() {
        this.listId = setInterval(() => {
            const [a, b] = this.state.list.slice(-2);
            // const c = a + b;
            // const newList = [...this.state.list];
            // newList.push(c);
            // this.setState({list: newList});
            this.setState({ list: [...this.state.list, a + b] });
        }, 1000)
    }

    componentWillUnmount() {
        clearInterval(this.listId);
    }

    render() {
        return <>{this.state.list.join(', ')}</>
    }
}